﻿using mds.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mds.Configuration
{
    public class BaseConfigService
    {
        private BaseConfigItem _configItem;
        private static BaseConfigService _instance = new BaseConfigService();
        public static BaseConfigService Instance
        {
            get
            {
                return _instance;
            }
        }
        private BaseConfigService()
        {
            init();
        }
        protected void init()
        {
            if (ConfigurationReader.Instance.Exists(ConfigurationDefine.RootFile))
                _configItem = ConfigurationReader.Instance.ReadForSingle<BaseConfigItem>(ConfigurationDefine.RootFile);
            else
                _configItem = new BaseConfigItem() { 
                 Version=0
                };
        }
        public BaseConfigItem GetConfig()
        {
            return _configItem;
        }
        public int LastVersion()
        {
            return _configItem.Version;
        }
    }
}
